package novel

import (
	"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
	"github.com/gin-gonic/gin"
)

type ChapterApi struct {
}

//ChapterByAuthorAndName 通过作者 和 书名获取章节
func (autoApi *ChapterApi) ChapterByAuthorAndName(c *gin.Context) {
	name := c.Query("name")
	author := c.Query("author")
	bookId := c.Query("bookId")
	chapters, err := novelService.ChapterByAuthorAndName(author, name, bookId)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
	}
	c.JSON(200, map[string]interface{}{"mixToc": chapters})

}

//ChapterByAuthorAndName 通过作者 和 书名获取章节
func (autoApi *ChapterApi) ContentByUrl(c *gin.Context) {
	urlStr := c.Query("url")
	content, err := novelService.ContentByUrl(urlStr)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
	}
	c.JSON(200, map[string]interface{}{"chapter": content})

}
